<template>
  <div class="cancel-order-page">
    <!-- 取消原因选择 -->
    <div class="reason-section">
      <h3 class="section-title">请选择取消原因</h3>
      <div class="reason-list">
        <div 
          v-for="(reason, index) in reasons" 
          :key="index" 
          class="reason-item"
          :class="{active: selectedReason === reason}"
          @click="selectedReason = reason"
        >
          {{ reason }}
        </div>
      </div>
    </div>

    <!-- 订单取消后的提示信息 -->
    <div class="notice-section">
      <h3 class="section-title">订单取消后：</h3>
      <ul class="notice-list">
        <li v-for="(item, index) in afterCancelTips" :key="index">
          <span class="notice-icon">•</span>
          <span>{{ item }}</span>
        </li>
      </ul>
    </div>

    <!-- 底部按钮 -->
    <div class="button-group">
      <button class="confirm-btn" @click="handleConfirm">确定</button>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      selectedReason: '',
      reasons: [
        '不想买了',
        '发现同款更低价',
        '商品买错了（颜色、尺寸选错了）',
        '忘记使用优惠券',
        '地址写错了',
        '发货时间太长',
        '其他'
      ],
      afterCancelTips: [
        '此订单所使用优惠券会退回（新用户券失效）',
        '此订单参加满赠券活动所送优惠券将失效',
        '此订单获得的成长值会被扣除'
      ]
    };
  },
  methods: {
    handleConfirm() {
      if (!this.selectedReason) {
        uni.showToast({
          title: '请选择取消原因',
          icon: 'none'
        });
        return;
      }
      
      uni.showToast({
        title: '订单取消成功',
        icon: 'success',
        duration: 1500,
        success: () => {
          // 提示显示完成后跳转页面
          setTimeout(() => {
            uni.navigateTo({
              url: '/pages/cancelprogress/cancelprogress'
            });
          }, 1500);
        }
      });
      
      // 提交到后端逻辑
      console.log('已选择取消原因:', this.selectedReason);
    }
  }
};
</script>

<style scoped>
.cancel-order-page {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px;
  background-color: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.section-title {
  font-size: 16px;
  color: #333;
  margin: 0 0 15px 0;
  font-weight: 500;
}

.reason-section {
  margin-bottom: 25px;
}

.reason-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.reason-item {
  padding: 12px 15px;
  border: 1px solid #eee;
  border-radius: 8px;
  font-size: 14px;
  color: #333;
  cursor: pointer;
  transition: all 0.2s;
}

.reason-item:hover {
  background-color: #f9f9f9;
}

.reason-item.active {
  border-color: #FF9500;
  background-color: rgba(255, 149, 0, 0.05);
  color: #FF9500;
}

.notice-section {
  margin-bottom: 30px;
}

.notice-list {
  padding-left: 5px;
  list-style: none;
}

.notice-list li {
  display: flex;
  align-items: flex-start;
  margin-bottom: 10px;
  font-size: 13px;
  color: #666;
  line-height: 1.5;
}

.notice-icon {
  margin-right: 8px;
  color: #FF9500;
}

.button-group {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  margin-top: 30px;
}

.confirm-btn {
  flex: 1;
  height: 44px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  background-color: #FF9500;
  color: #fff;
}

.confirm-btn:hover {
  background-color: #ffaa33;
}

.confirm-btn:disabled {
  background-color: #ccc;
  cursor: not-allowed;
}
</style>